/*
 * @Author: sean_kei@163.com
 * @Date: 2021-06-08 15:07:28
 * @LastEditors: sean_kei@163.com
 * @LastEditTime: 2022-08-03 13:11:02
 */
package com.wxhandle.cleandemo.application.dto.identity;

import java.util.List;


import lombok.Data;
import lombok.RequiredArgsConstructor;

@Data
@RequiredArgsConstructor
public class SysClaimDto {

    /**
     * 声明标识，字符串，唯一
     */
    private String id;

    /**
     * 声明描述
     */
    private String description;

    /**
     * Action或Url地址
     */
    private String action;

    /**
     * 顺序号
     */
    private int sorting;

    private List<SysClaimDto> children;

    public static SysClaimDto of(VueMenuDto vm, int i) {
        SysClaimDto claimDto = new SysClaimDto();
        claimDto.setId(vm.getName());
        claimDto.setDescription(vm.getMeta().getTitle());
        claimDto.setAction(vm.getPath());
        claimDto.setSorting(i);
        if(null == vm.getChildren()){
            int j=0;
            for(VueMenuDto sm : vm.getChildren()){
                if(!sm.getMeta().isHideInMenu()){
                    SysClaimDto child= SysClaimDto.of(sm, j++);
                    claimDto.getChildren().add(child);
                }
            }
        }
        return claimDto;
    }

}
